/*******************************************************************************
 *
 * Pentaho Big Data
 *
 * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.runtime.test.test.impl;

import org.pentaho.runtime.test.RuntimeTest;
import org.pentaho.runtime.test.result.RuntimeTestResult;
import org.pentaho.runtime.test.result.RuntimeTestResultEntry;
import org.pentaho.runtime.test.result.RuntimeTestResultSummary;
import org.pentaho.runtime.test.result.org.pentaho.runtime.test.result.impl.RuntimeTestResultSummaryImpl;

import java.util.List;

/**
 * Created by bryan on 8/12/15.
 */
public class RuntimeTestResultImpl implements RuntimeTestResult {
  private final RuntimeTest runtimeTest;
  private final boolean isDone;
  private final RuntimeTestResultSummary runtimeTestResultSummary;
  private final long timeTaken;

  public RuntimeTestResultImpl( RuntimeTest runtimeTest, boolean isDone,
                                RuntimeTestResultSummary runtimeTestResultSummary,
                                long timeTaken ) {
    this.runtimeTest = runtimeTest;
    this.isDone = isDone;
    this.runtimeTestResultSummary =
      runtimeTestResultSummary == null ? new RuntimeTestResultSummaryImpl( null ) : runtimeTestResultSummary;
    this.timeTaken = timeTaken;
  }

  @Override public RuntimeTest getRuntimeTest() {
    return runtimeTest;
  }

  @Override public boolean isDone() {
    return isDone;
  }

  @Override public long getTimeTaken() {
    return timeTaken;
  }

  @Override public RuntimeTestResultEntry getOverallStatusEntry() {
    return runtimeTestResultSummary.getOverallStatusEntry();
  }

  @Override public List<RuntimeTestResultEntry> getRuntimeTestResultEntries() {
    return runtimeTestResultSummary.getRuntimeTestResultEntries();
  }

  //OperatorWrap isn't helpful for autogenerated methods
  //CHECKSTYLE:OperatorWrap:OFF

  @Override public String toString() {
    return "RuntimeTestResultImpl{" +
      "runtimeTest=" + runtimeTest +
      ", isDone=" + isDone +
      ", runtimeTestResultSummary=" + runtimeTestResultSummary +
      ", timeTaken=" + timeTaken +
      '}';
  }

  //CHECKSTYLE:OperatorWrap:ON
}
